<?php

namespace app\base;

use common\base\BaseController;
use common\services\ClientServices;
use Yii;
use yii\filters\VerbFilter;
use yii\filters\AccessControl;

class BaseAppController extends BaseController
{

    public function init()
    {
        parent::init();
        if (empty($this->clientSection)) {
            $LvzinDSID = Yii::$app->request->get('LvzinDSID');
            if (empty($LvzinDSID)) {
                $LvzinDSID = '00000';
            }
            $clientServices = new ClientServices();
            $client = $clientServices->getClient($LvzinDSID);
            $this->clientSection = $client->section;//终端对应的学段，空则表示所有信息
            $this->clientThemes = $client->template_key;
        }
        //设置主题路径
        $themes = Yii::getAlias("@app").DIRECTORY_SEPARATOR.'themes'.DIRECTORY_SEPARATOR.$this->clientThemes;
        $this->module->setViewPath($themes);
        if (!Yii::$app->user->getIsGuest()) {
            $userId = Yii::$app->user->getId();
        }
    }

    /**
     * {@inheritdoc}
     */
    public function behaviors()
    {
        return [
            'verbs' => [
                'class' => VerbFilter::className(),
                'actions' => [
                    //'index' => ['post'],
                ],
            ],
        ];
    }
}